<?php

namespace haibao\erp\data\product;

use \haibao\erp\model\filter\product\ProductContentInfo as ProductContentInfoFilter;
use \haibao\erp\model\data\product\ProductRelCategoryProperty as ProductRelCategoryPropertyModelData;

class ProductContentInfo extends \haibao\erp\data\BaseMysql{

	public function __construct(){
		parent::__construct('\haibao\erp\model\data\product\ProductContentInfo');
	}


    public function getProductContentInfoByProductIds($productIds){
        if(is_array($productIds)){
            $productArr=implode(',',$productIds);
            $str=preg_replace('/(\d+)/','%s',$productArr);
            $sql='select * from ProductContentInfo where ProductId in ('.$str.') ORDER BY DataType';
            $result=$this->query($sql,$productIds);
        }else{
            $sql='select * from ProductContentInfo where ProductId=%s ORDER BY DataType';
            $result=$this->query($sql,array(intval($productIds)));
        }
        $list=array();
        while ($result->fetch_assoc()) {
            if($result->getData('DataType')==\haibao\erp\model\data\product\ProductContentInfo::DATA_TYPE_IMAGE_PRO){
                $list[$result->getData('ProductId')][$result->getData('DataType')][] = $result->getData('ContentInfo');
            }else{
                $list[$result->getData('ProductId')][$result->getData('DataType')]=$result->getData('ContentInfo');
            }
        }
        return $list;
    }
    public  function getImgeInfobyIdArr(&$infoArr){
        if (is_array($infoArr)){
            $ids=implode(',',$infoArr);
            $str=preg_replace('/(\d+)/','%s',$ids);
            $sql='select * from ImageLibrary where Id in ('.$str.')';
            $result=$this->query($sql,$infoArr);
        }else{
            $sql='select * from ImageLibrary where Id=%s';
            $result=$this->query($sql,array(intval($infoArr)));
        }
        $list=array();
        while ($result->fetch_assoc()) {
            $list[$result->getData('Id')]=$result->getData('originalUrl');
        }
        return $list;
    }



}